package com.example.demo.controller;


import com.example.demo.entity.ResponseInfo;
import com.example.demo.entity.SysLog;
import com.example.demo.service.SysLogService;
import com.example.demo.utils.PageInfoNew;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/sysLog")
@Api(tags = "系统日志管理")
public class SysLogController {

    @Resource
    SysLogService sysLogService;

    /**
     * 分页接口
     */
    @GetMapping("/page")
    @ApiOperation(value = "系统日志分页接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "页数", required = true, dataType = "int"),
            @ApiImplicitParam(name = "pageSize", value = "每页长度", required = true, dataType = "int"),
            @ApiImplicitParam(name = "url", value = "路径，模糊搜索", required = false, dataType = "String"),
            @ApiImplicitParam(name = "code", value = "返回状态码，精准搜索", required = false, dataType = "String")
    })
    public ResponseInfo<PageInfoNew<SysLog>> getProjectPage(@RequestParam int pageNum, @RequestParam int pageSize,
                                                            @RequestParam(value = "url", required = false) String url,
                                                            @RequestParam(value = "code", required = false) String code) {
        return ResponseInfo.successInfo(sysLogService.findWithPage(pageNum, pageSize, url, code));
    }

}
